import { defineStore } from "pinia";
import { loginAPI } from "@/api/user";
import { ref } from "vue";

export const useUserData = defineStore(
  "UserStore",
  () => {
    //state
    const userData = ref({});

    //action
    const getUserData = async ({ account, password }) => {
      const res = await loginAPI({ account, password });
      userData.value = res.result;
      console.log("res11111", res);
    };
    const clearUserData = () => {
      userData.value = {};
    };
    return { userData, getUserData, clearUserData };
  },
  {
    persist: true,
  }
);
